##############################################################
#Figure B8: Placebo Estimates
##############################################################

sen.prec <- read.dta13("./temp/figb8adata.dta")

newdf <- sen.prec %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(1,2,3,4,5,6,7,8)

g1<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=logd_coef, ymin=logd_ci_upper, 
                                          ymax=logd_ci_lower), color="grey60",
                  size=2, lwd=2, fatten=2, fill="goldenrod1", shape=21) +
  ylim(-.5,1) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6", "7", "8"), 
                   labels= c("2002", "2004", "2006", "2008", "2010", "2012", "2014", "All")) + 
  xlab("Election Year")  + ylab("Estimate on Democrat Share U.S. Senate") +
  geom_hline(yintercept=0, col="grey60", lwd=1, lty="dashed", alpha=.6)  + 
  theme(plot.title = element_text(hjust = .5, face="bold", size=15, colour = "grey60"),
        axis.text= element_text(size = 12),
        axis.title = element_text(size=15)) 
g1

##################
## Placebo House 
##################

hou.prec <- read.dta13("./temp/figb8bdata.dta")

newdf <- hou.prec %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(1,2,3,4,5,6,7,8)

g2<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=logd_coef, ymin=logd_ci_upper, 
                                          ymax=logd_ci_lower), color="grey60",
                  size=2, lwd=2, fatten=2, fill="goldenrod1", shape=21) +
  ylim(-.5,1) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6", "7", "8"), 
                   labels= c("2002", "2004", "2006", "2008", "2010", "2012", "2014", "All")) + 
  xlab("Election Year")  + ylab("Estimate on Democrat Share U.S. House") +
  geom_hline(yintercept=0, col="grey60", lwd=1, lty="dashed", alpha=.6)  + 
  theme(plot.title = element_text(hjust = .5, face="bold", size=15, colour = "grey60"),
        axis.text= element_text(size = 12),
        axis.title = element_text(size=15)) 
g2


library(ggpubr)
ggarrange(g1, g2)
ggsave("./figures/figb8.pdf")